﻿using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Text;

using Utility.Config;
using Utility.Data;
using Utility.Encrypt;
using Utility.IO;
using Utility.Tool;

//----------------------------------------------------------------*/
// 版权所有：
// 文 件 名：DbBase.cs
// 功能描述：数据库访问基类
// 创建标识：m.sh.lin0328@163.com 2014/7/11 21:45:36
// 修改描述：
//----------------------------------------------------------------*/
namespace DataBase.Core
{
    internal abstract class DbBase : IDbHelper, IDisposable
    {
        protected LogHelper Logger = new LogHelper(Common.DBConfig.LogName);/// 创建系统异常日志
        private static Object locker = new Object();
        protected string connectionString = "";// 数据库连接字符串

        #region 属性
        //命令
        private DbCommand _dbCommand = null;
        /// <summary>
        /// 命令
        /// </summary>
        public DbCommand DbCommand
        {
            get
            {
                return this._dbCommand;
            }
            set
            {
                this._dbCommand = value;
            }
        }
        /// <summary>
        /// 
        /// </summary>
        public virtual string Pre
        {
            get
            {
                return this.Pre;
            }
        }
        #endregion

        #region 数据库连接
        public DbBase(string conn)
        {
            connectionString = conn;
        }

        private SqlDatabase _db = null;
        /// <summary>
        /// 取得单一实例
        /// </summary>
        public SqlDatabase GetDatabase()
        {
            //在并发时，使用单一对象
            if (this._db == null)
            {
                if (Common.DBConfig.IsEncrypt)//判断是否加密
                    this._db = new SqlDatabase(DESEncrypt.Decrypt(connectionString));
                else
                    this._db = new SqlDatabase(connectionString);
                return this._db;
            }
            else
            {
                lock (locker)
                {
                    return this._db;
                }
            }
        }
        #endregion

        #region 通过参数类构造键值

        /// <summary>
        /// 通过Hashtable对象构造键值
        /// </summary>
        /// <param name="cmd">SQL命令</param>
        /// <param name="ht">参数化 必须加@</param>
        protected void AddInParameter(DbCommand cmd, Hashtable ht)
        {
            if (ht == null) return;
            foreach (string key in ht.Keys)
            {
                if (key == "Msg")
                {
                    this.GetDatabase().AddOutParameter(cmd, key.Replace("@", this.Pre), DbType.AnsiString, 1000);
                }
                else
                {
                    this.GetDatabase().AddInParameter(cmd, key.Replace("@", this.Pre), DbType.AnsiString, ht[key]);
                }
            }
        }
        /// <summary>
        /// 通过Hashtable对象构造键值
        /// </summary>
        /// <param name="cmd">SQL命令</param>
        /// <param name="_params">参数化</param>
        protected void AddMoreParameter(DbCommand cmd, Hashtable ht)
        {
            if (ht == null) return;
            foreach (string key in ht.Keys)
            {
                if (key.StartsWith("OUT_"))
                {
                    string tmp = key.Remove(0, 4);
                    this.GetDatabase().AddOutParameter(cmd, this.Pre + tmp, DbType.AnsiString, 1000);
                }
                else
                {
                    this.GetDatabase().AddInParameter(cmd, this.Pre + key, DbType.AnsiString, ht[key]);
                }
            }
        }
        #endregion

        #region 返回影响行数
        /// <summary>
        /// 根据SQL返回影响行数
        /// </summary>
        /// <param name="sql">sql语句</param>
        /// <returns></returns>
        public object GetObjectValue(string sql)
        {
            return this.GetObjectValue(sql, null);
        }
        /// <summary>
        /// 根据SQL返回影响行数,带参数
        /// </summary>
        /// <param name="sql">sql语句</param>
        /// <param name="ht">参数化</param>
        /// <returns></returns>
        public object GetObjectValue(string sql, Hashtable ht)
        {
            try
            {
                this._dbCommand = this.GetDatabase().GetSqlStringCommand(sql);
                this.AddInParameter(this._dbCommand, ht);
                return this._db.ExecuteScalar(this._dbCommand);
            }
            catch (Exception e)
            {
                Logger.WriteLog("-----------根据SQL返回影响行数-----------\r\n" + sql + "\r\n" + e.Message + "\r\n");
                return null;
            }
        }
        #endregion

        #region 根据SQL执行
        /// <summary>
        ///  根据SQL执行
        /// </summary>
        /// <param name="sql">sql语句</param>
        /// <returns>object</returns>
        public int ExecuteBySql(string sql)
        {
            return this.ExecuteBySql(sql, null);
        }
        /// <summary>
        ///  根据SQL执行,带参数
        /// </summary>
        /// <param name="sql">sql语句</param>
        /// <param name="ht">参数化</param>
        /// <returns>object</returns>
        public int ExecuteBySql(string sql, Hashtable ht)
        {
            int num = 0;
            try
            {
                this._dbCommand = this.GetDatabase().GetSqlStringCommand(sql);
                this.AddInParameter(this._dbCommand, ht);
                using (DbConnection conn = this._db.CreateConnection())
                {
                    conn.Open();
                    DbTransaction trans = conn.BeginTransaction();
                    try
                    {
                        num = this._db.ExecuteNonQuery(this._dbCommand, trans);
                        trans.Commit();
                    }
                    catch (Exception e)
                    {
                        trans.Rollback();
                        num = -1;
                        Logger.WriteLog("-----------根据SQL执行,回滚事物-----------\r\n" + sql + "\r\n" + e.Message + "\r\n返回值" + num + "\r\n");
                    }
                    finally
                    {
                        conn.Close();
                    }
                }
            }
            catch (Exception e)
            {
                Logger.WriteLog("-----------执行sql语句服务器连接失败-----------\r\n" + e.Message + "\r\n返回值" + num + "\r\n");
            }
            return num;
        }

        /// <summary>
        /// 批量执行sql语句
        /// </summary>
        /// <param name="sqls"></param>
        /// <param name="m_param"></param>
        /// <returns></returns>
        public int BatchExecuteBySql(string[] sqls, object[] param)
        {
            int num = 0;
            StringBuilder sql_Log = new StringBuilder();
            try
            {
                using (DbConnection connection = this.GetDatabase().CreateConnection())
                {
                    connection.Open();
                    DbTransaction transaction = connection.BeginTransaction();
                    try
                    {
                        for (int i = 0; i < sqls.Length; i++)
                        {
                            if (sqls[i] == null)
                                continue;

                            StringBuilder builder = new StringBuilder(sqls[i]);
                            sql_Log.Append(builder + "\r\n");
                            if (builder != null)
                            {
                                Hashtable paramArray = (Hashtable)param[i];
                                DbCommand sqlStringCommand = this._db.GetSqlStringCommand(builder.ToString());
                                this.AddInParameter(sqlStringCommand, paramArray);
                                num = this._db.ExecuteNonQuery(sqlStringCommand, transaction);
                            }
                        }
                        transaction.Commit();
                        connection.Close();
                        return num;
                    }
                    catch (Exception exception)
                    {
                        num = -1;
                        transaction.Rollback();
                        this.Logger.WriteLog("-----------批量执行sql语句-----------\r\n" + sql_Log.ToString() + "\r\n" + exception.Message + "\r\n返回值" + num + "\r\n");
                    }
                }
            }
            catch (Exception e)
            {
                Logger.WriteLog("-----------批量执行sql语句服务器连接失败-----------\r\n" + e.Message + "\r\n返回值" + num + "\r\n");
            }
            return num;
        }
        #endregion

        #region DataTable 数据集
        /// <summary>
        /// 获取数据表，没有条件
        /// </summary>
        /// <param name="TargetTable">目标表名</param>
        /// <returns>DataTable</returns>
        public DataTable GetDataTable(string TargetTable)
        {
            string sql = String.Empty;
            try
            {
                sql = "SELECT * FROM " + TargetTable + "";
                this._dbCommand = this.GetDatabase().GetSqlStringCommand(sql);
                return DataReaderHelper.DataTableToIDataReader(this._db.ExecuteReader(this._dbCommand));
            }
            catch (Exception e)
            {
                Logger.WriteLog("-----------获取数据集DataTable-----------\r\n" + sql + "\r\n" + e.Message + "\r\n");
                return null;
            }
        }
        /// <summary>
        /// 获取数据表,排序
        /// </summary>
        /// <param name="TargetTable">目标表名</param>
        /// <param name="orderField">排序字段</param>
        /// <param name="orderType">排序类型</param>
        /// <returns></returns>
        public DataTable GetDataTable(string TargetTable, string orderField, string orderType)
        {
            string sql = String.Empty;
            try
            {
                sql = "SELECT * FROM " + TargetTable + " ORDER BY " + orderField + " " + orderType + "";
                this._dbCommand = this.GetDatabase().GetSqlStringCommand(sql);
                return DataReaderHelper.DataTableToIDataReader(this._db.ExecuteReader(this._dbCommand));
            }
            catch (Exception e)
            {
                Logger.WriteLog("-----------获取数据集DataTable-----------\r\n" + sql + "\r\n" + e.Message + "\r\n");
                return null;
            }
        }
        /// <summary>
        /// 根据 SQL 返回 DataTable 数据集
        /// </summary>
        /// <param name="sql">sql语句</param>
        /// <returns>DataTable</returns>
        public DataTable GetDataTableBySQL(string sql)
        {
            return this.GetDataTableBySQL(sql, null);
        }
        /// <summary>
        /// 根据 SQL 返回 DataTable 数据集，带参数
        /// </summary>
        /// <param name="sql">sql语句</param>
        /// <param name="ht">参数化</param>
        /// <returns>DataTable</returns>
        public DataTable GetDataTableBySQL(string sql, Hashtable ht)
        {
            try
            {
                this._dbCommand = this.GetDatabase().GetSqlStringCommand(sql);
                this.AddInParameter(this._dbCommand, ht);
                return DataReaderHelper.DataTableToIDataReader(this._db.ExecuteReader(this._dbCommand));
            }
            catch (Exception e)
            {
                Logger.WriteLog("-----------获取数据集DataTable-----------\r\n" + sql + "\r\n" + e.Message + "\r\n");
                return null;
            }
        }
        /// <summary>
        /// 摘要:
        ///     执行一存储过程DataTable
        /// 参数：
        ///     procName：存储过程名称
        ///     Hashtable：传入参数字段名
        /// </summary>
        public DataTable GetDataTableProc(string procName, Hashtable ht)
        {
            try
            {
                this._dbCommand = this.GetDatabase().GetStoredProcCommand(procName);
                this.AddInParameter(this._dbCommand, ht);
                using (DbConnection conn = this._db.CreateConnection())
                {
                    conn.Open();
                    DbTransaction trans = conn.BeginTransaction();
                    return DataReaderHelper.DataTableToIDataReader(this._db.ExecuteReader(this._dbCommand));
                }
            }
            catch (Exception e)
            {
                Logger.WriteLog("-----------执行一存储过程DataTable-----------\r\n" + procName.ToString() + "\r\n" + e.Message + "\r\n");
                return null;
            }
        }
        /// <summary>
        /// 执行一存储过程返回数据表 返回多个值
        /// <param name="procName">存储过程名称</param>
        /// <param name="ht">Hashtable</param>
        /// <param name="rs">Hashtable</param>
        public DataTable GetDataTableProcReturn(string procName, Hashtable ht, ref Hashtable rs)
        {
            try
            {
                this._dbCommand = this.GetDatabase().GetStoredProcCommand(procName);
                this.AddMoreParameter(this._dbCommand, ht);
                DataSet ds = this._db.ExecuteDataSet(this._dbCommand);
                rs = new Hashtable();
                foreach (string key in ht.Keys)
                {
                    if (key.StartsWith("OUT_"))
                    {
                        string tmp = key.Remove(0, 4);
                        object val = this._db.GetParameterValue(this._dbCommand, this.Pre + tmp);
                        rs[key] = val;
                    }
                }
                return ds.Tables[0];
            }
            catch (Exception e)
            {
                Logger.WriteLog("-----------执行一存储过程DataTable返回多个值-----------\r\n" + procName.ToString() + rs + "\r\n" + e.Message + "\r\n");
                return null;
            }
        }
        #endregion

        #region 返回 IList
        /// <summary>
        /// 根据 SQL 返回 IList
        /// </summary>
        /// <typeparam name="T">实体类</typeparam>
        /// <param name="sql">语句</param>
        /// <returns></returns>
        public IList GetDataListBySQL<T>(string sql)
        {
            return this.GetDataListBySQL<T>(sql, null);
        }

        /// <summary>
        /// 根据 SQL 返回 IList,带参数 (比DataSet效率高)
        /// </summary>
        /// <typeparam name="T">实体类</typeparam>
        /// <param name="sql">Sql语句</param>
        /// <param name="ht">参数化</param>
        /// <returns></returns>
        public IList GetDataListBySQL<T>(string sql, Hashtable ht)
        {
            IList list = new List<T>();
            this._dbCommand = this.GetDatabase().GetSqlStringCommand(sql);
            this.AddInParameter(this._dbCommand, ht);
            using (IDataReader dataReader = this._db.ExecuteReader(this._dbCommand))
            {
                list = DataReaderHelper.ReaderToList<T>(dataReader);
            }
            return list;
        }
        #endregion

        #region 调用存储过程
        /// <summary>
        /// 调用存储过程
        /// </summary>
        /// <param name="procName">存储过程名称</param>
        /// <param name="ht">参数化</param>
        public int ExecuteByProc(string procName, Hashtable ht)
        {
            int num = 0;
            try
            {
                DbCommand com = this.GetDatabase().GetStoredProcCommand(procName);
                this.AddInParameter(com, ht);
                using (DbConnection connection = this._db.CreateConnection())
                {
                    connection.Open();
                    DbTransaction transaction = connection.BeginTransaction();
                    try
                    {
                        num = this._db.ExecuteNonQuery(com, transaction);
                        transaction.Commit();
                    }
                    catch (Exception exception)
                    {
                        transaction.Rollback();
                        Logger.WriteLog("-----------执行存储过程-----------\r\n" + procName + "\r\n" + exception.Message + "\r\n");
                    }
                    connection.Close();
                    return num;
                }
            }
            catch (Exception e)
            {
                Logger.WriteLog("-----------执行存储过程服务器连接失败-----------\r\n" + procName + "\r\n" + e.Message + "\r\n");
            }
            return num;
        }

        public int ExecuteByProcNotTran(string procName, Hashtable ht)
        {
            int num = 0;
            try
            {
                DbCommand com = this.GetDatabase().GetStoredProcCommand(procName);
                this.AddInParameter(com, ht);
                using (DbConnection connection = this._db.CreateConnection())
                {
                    connection.Open();
                    try
                    {
                        num = this._db.ExecuteNonQuery(com);
                    }
                    catch (Exception exception)
                    {
                        Logger.WriteLog("-----------执行存储过程-----------\r\n" + procName + "\r\n" + exception.Message + "\r\n");
                    }
                    connection.Close();
                    return num;
                }
            }
            catch (Exception e)
            {
                Logger.WriteLog("-----------执行存储过程服务器连接失败-----------\r\n" + procName + "\r\n" + e.Message + "\r\n");
            }
            return num;
        }
        /// <summary>
        /// 调用存储过程返回指定消息
        /// </summary>
        /// <param name="procName">存储过程名称</param>
        /// <param name="ht">Hashtable</param>
        /// <param name="msg">OutPut rs</param>
        public int ExecuteByProcReturn(string procName, Hashtable ht, ref Hashtable rs)
        {
            int num = 0;
            try
            {
                DbCommand com = this.GetDatabase().GetStoredProcCommand(procName);
                this.AddMoreParameter(com, ht);
                using (DbConnection connection = this._db.CreateConnection())
                {
                    connection.Open();
                    DbTransaction transaction = connection.BeginTransaction();
                    try
                    {
                        num = this._db.ExecuteNonQuery(com, transaction);
                        transaction.Commit();
                    }
                    catch
                    {
                        transaction.Rollback();
                    }
                    connection.Close();
                }
                rs = new Hashtable();
                foreach (string str in ht.Keys)
                {
                    if (str.StartsWith("OUT_"))
                    {
                        object parameterValue = this._db.GetParameterValue(com, this.Pre + str.Remove(0, 4));
                        rs[str] = parameterValue;
                    }
                }
                return num;
            }
            catch (Exception exception)
            {
                this.Logger.WriteLog("-----------执行存储过程返回指定消息-----------\n" + procName + "\n" + exception.Message);
            }
            return num;
        }
        /// <summary>
        /// 调用存储过程返回指定消息
        /// </summary>
        /// <param name="procName">存储过程名称</param>
        /// <param name="ht">Hashtable</param>
        /// <param name="msg">OutPut Msg</param>
        public int ExecuteByProcReturnMsg(string procName, Hashtable ht, ref object msg)
        {
            int num = 0;
            try
            {
                DbCommand com = this.GetDatabase().GetStoredProcCommand(procName);
                this.AddInParameter(com, ht);
                using (DbConnection connection = this._db.CreateConnection())
                {
                    connection.Open();
                    DbTransaction transaction = connection.BeginTransaction();
                    try
                    {
                        num = this._db.ExecuteNonQuery(com, transaction);
                        transaction.Commit();
                    }
                    catch
                    {
                        transaction.Rollback();
                    }
                    connection.Close();
                }
                msg = this._db.GetParameterValue(com, "@Msg");
            }
            catch (Exception exception)
            {
                this.Logger.WriteLog("-----------执行存储过程返回指定消息-----------\n" + procName + "\n" + exception.Message);
            }
            return num;

        }
        #endregion

        #region 增、删、改、查
        /// <summary>
        /// 表单提交：新增，修改
        ///     参数：
        ///     tableName:表名
        ///     pkName：字段主键
        ///     pkValue：字段值
        ///     ht：参数
        /// </summary>
        /// <returns></returns>
        public bool AddOrEdit(string tableName, string pkName, string pkValue, Hashtable ht)
        {
            if (string.IsNullOrEmpty(pkValue))
            {
                if (this.InsertByHashtable(tableName, ht) > 0)
                    return true;
                else
                    return false;
            }
            else
            {
                if (this.Update(tableName, pkName, pkValue, ht) > 0)
                    return true;
                else
                    return false;
            }
        }
        /// <summary>
        /// 根据唯一ID获取Hashtable
        /// </summary>
        /// <param name="tableName">表名</param>
        /// <param name="pkName">字段主键</param>
        /// <param name="pkValue">字段值</param>
        /// <returns></returns>
        public Hashtable GetHashtableById(string tableName, string pkName, string pkValue)
        {
            StringBuilder sb = new StringBuilder();
            Hashtable ht = new Hashtable();
            ht.Add(this.Pre + "ID", pkValue);

            sb.Append("Select * From ").Append(tableName).Append(" Where ").Append(pkName).Append("=" + this.Pre + "ID");
            DataTable dt = this.GetDataTableBySQL(sb.ToString(), ht);
            return DataTableHelper.DataTableToHashtable(dt);
        }
        /// <summary>
        /// 判断数据是否存在
        /// </summary>
        /// <param name="tableName">表名</param>
        /// <param name="pkName">字段主键</param>
        /// <param name="pkValue">字段值</param>
        /// <returns></returns>
        public int IsExist(string tableName, string pkName, string pkValue)
        {
            string sql = "Select Count(1) from " + tableName + " Where " + pkName + " = " + this.Pre + "" + pkName;
            Hashtable ht = new Hashtable();
            ht.Add(this.Pre + pkName + "", pkValue);

            return ConvertHelper.ToInt(this.GetObjectValue(sql, ht));
        }

        /// <summary>
        /// 通过Hashtable插入数据
        /// </summary>
        /// <param name="tableName">表名</param>
        /// <param name="ht">Hashtable</param>
        /// <returns>int</returns>
        public virtual int InsertByHashtable(string tableName, Hashtable ht)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(" Insert Into ");
            sb.Append(tableName);
            sb.Append("(");
            StringBuilder sp = new StringBuilder();
            StringBuilder sb_prame = new StringBuilder();
            foreach (string key in ht.Keys)
            {
                sb_prame.Append("," + key);
                sp.Append("," + this.Pre + "" + key);
            }
            sb.Append(sb_prame.ToString().Substring(1, sb_prame.ToString().Length - 1) + ") Values (");
            sb.Append(sp.ToString().Substring(1, sp.ToString().Length - 1) + ")");
            int _object = this.ExecuteBySql(sb.ToString(), ht);
            return _object;
        }

        /// <summary>
        /// 通过Hashtable修改数据
        /// </summary>
        /// <param name="tableName">表名</param>
        /// <param name="pkName">字段主键</param>
        /// <param name="pkValueue"></param>
        /// <param name="ht">Hashtable</param>
        /// <returns>int</returns>
        public int Update(string tableName, string pkName, string pkValue, Hashtable ht)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(" Update ");
            sb.Append(tableName);
            sb.Append(" Set ");
            bool isFirstValue = true;
            foreach (string key in ht.Keys)
            {
                if (isFirstValue)
                {
                    isFirstValue = false;
                    sb.Append(key);
                    sb.Append("=");
                    sb.Append(this.Pre + key);
                }
                else
                {
                    sb.Append("," + key);
                    sb.Append("=");
                    sb.Append(this.Pre + key);
                }
            }
            sb.Append(" Where ").Append(pkName).Append("=").Append(this.Pre + pkName);
            ht[pkName] = pkValue;
            int _object = this.ExecuteBySql(sb.ToString(), ht);
            return _object;
        }
        /// <summary>
        /// 通过Hashtable修改数据
        /// </summary>
        /// <param name="tableName">表名</param>
        /// <param name="strWhere">条件 不加where</param>
        /// <param name="ht">Hashtable</param>
        /// <returns>int</returns>
        public int UpdateByHashtable(string tableName, string strWhere, Hashtable ht)
        {
            if (String.IsNullOrEmpty(strWhere))
                return 0;

            StringBuilder sb = new StringBuilder();
            sb.Append(" Update ");
            sb.Append(tableName);
            sb.Append(" Set ");
            bool isFirstValue = true;
            foreach (string key in ht.Keys)
            {
                if (isFirstValue)
                {
                    isFirstValue = false;
                    sb.Append(key);
                    sb.Append("=");
                    sb.Append(this.Pre + key);
                }
                else
                {
                    sb.Append("," + key);
                    sb.Append("=");
                    sb.Append(this.Pre + key);
                }
            }
            sb.Append(" Where ").Append(strWhere);

            int _object = this.ExecuteBySql(sb.ToString(), ht);
            return _object;
        }
        /// <summary>
        /// 删除数据
        /// </summary>
        /// <param name="tableName">表名</param>
        /// <param name="pkName">字段主键</param>
        /// <param name="pkValue">字段值</param>
        /// <returns></returns>
        public int DeleteData(string tableName, string pkName, string pkValue)
        {
            StringBuilder sb = new StringBuilder("Delete From " + tableName + " Where " + pkName + " = " + this.Pre + "ID");
            Hashtable ht = new Hashtable();
            ht.Add(this.Pre + "ID", pkValue);
            return this.ExecuteBySql(sb.ToString(), ht);
        }

        /// <summary>
        /// 批量删除
        /// </summary>
        /// <param name="tableName">表名</param>
        /// <param name="pkName">字段主键</param>
        /// <param name="pkValue">字段值</param>
        /// <returns></returns>
        public int BatchDelete(string tableName, string pkName, object[] pkValues)
        {
            Hashtable ht = new Hashtable();
            int index = 0;
            string str = this.Pre + "ID" + index;
            StringBuilder sql = new StringBuilder("DELETE FROM " + tableName + " WHERE " + pkName + " IN (");
            foreach (object obj in pkValues)
            {
                str = this.Pre + "ID" + index;
                sql.Append(str).Append(",");
                ht.Add(str, obj);
                index++;
            }
            sql.Remove(sql.Length - 1, 1);
            sql.Append(")");
            return this.ExecuteBySql(sql.ToString(), ht);
        }
        #endregion

        #region 数据分页
        /// <summary>
        /// 数据分页
        /// </summary>
        /// <param name="sql">sql语句：当作数据表使用</param>
        /// <param name="ht">参数</param>
        /// <param name="sortBy">排序 如：id desc </param>
        /// <param name="pageIndex">页索引</param>
        /// <param name="pageSize">页大小</param>
        /// <param name="count">总记录数</param>
        /// <returns>DataTable</returns>
        public virtual DataTable GetPageList(string sql, Hashtable ht, string sortBy, int pageIndex, int pageSize, ref int count)
        {
            return null;
        }
        public virtual DataTable GetPageList(string tableName, string primaryKey, string showFields, int pageIndex, int pageSize, string whereStr, string sortBy, ref int count)
        {
            return null;
        }
        #endregion

        #region BulkCopy 批量导入
        /// <summary>
        /// 利用Net BulkCopy 批量导入数据库,速度超快
        /// </summary>
        /// <param name="dt">源内存数据表</param>
        /// <returns></returns>
        public virtual bool BulkCopyImport(DataTable dt)
        {
            return false;
        }
        #endregion

        #region IDisposable 成员
        /// <summary>
        /// 内存回收
        /// </summary>
        public void Dispose()
        {
            if (this._dbCommand != null)
            {
                this._dbCommand.Dispose();
            }
        }
        #endregion
    }
}
